package cn.xuqiudong.backend.base.helper;

import cn.xuqiudong.backend.module.system.user.model.SysUser;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 描述:
 *      存放在session中的用户信息
 * @author Vic.xu
 * @since 2025-03-10 9:56
 */
public class SessionUserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer userId;

    private String username;

    private String nickName;

    private List<String> roles;

    private List<String> permissions;

    public SessionUserInfo() {
        roles = new ArrayList<>();
        permissions = new ArrayList<>();
    }

    public SessionUserInfo(SysUser user) {
        this();
        this.userId = user.getId();
        this.username = user.getUsername();
        this.nickName = user.getNickname();
        // 加入用户名作为role 方便测试
        roles.add(user.getUsername());
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public List<String> getRoles() {
        return roles;
    }

    public void setRoles(List<String> roles) {
        this.roles = roles;
    }

    public List<String> getPermissions() {
        return permissions;
    }

    public void setPermissions(List<String> permissions) {
        this.permissions = permissions;
    }

    private List<String> getButtons(){
        return permissions;
    }
}
